package com.csw.shuanfa.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class FileOperate {
    public static void main(String[] args) throws IOException {
        File file = new File("D://" + "aa.txt");
        if (!file.exists()) {
            file.createNewFile();
        }
        //读
        Scanner sc = new Scanner(file);
        while (sc.hasNextLine()) {
           String aa=sc.nextLine();
        }

        //指定字符集，追加写入文件
        FileUtils.writeStringToFile(file, JSON.toJSONString(new JSONObject()) + "\r\n", "UTF-8", true);



    }
}
